package com.ruoyi.web.controller.business;

import java.util.Date;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.annotation.DeterminableImports;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HealthDailyInfo;
import com.ruoyi.system.service.IHealthDailyInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 健康日报详情Controller
 * 
 * @author ruoyi
 * @date 2020-02-21
 */
@Controller
@RequestMapping("/healthinfo/healthdailyInfo")
public class HealthDailyInfoController extends BaseController
{
    private String prefix = "healthinfo/healthdailyInfo";

    @Autowired
    private IHealthDailyInfoService healthDailyInfoService;

    @RequiresPermissions("healthinfo:healthdailyInfo:view")
    @GetMapping()
    public String healthdailyInfo()
    {
        return prefix + "/healthdailyInfo";
    }

    /**
     * 查询健康日报详情列表
     */
    @RequiresPermissions("healthinfo:healthdailyInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HealthDailyInfo healthDailyInfo)
    {
        startPage();
        List<HealthDailyInfo> list = healthDailyInfoService.selectHealthDailyInfoList(healthDailyInfo);
        return getDataTable(list);
    }

    @RequiresPermissions("healthinfo:healthdailyInfo:queryByMobile")
    @PostMapping("/queryByMobile")
    @ResponseBody
    public HealthDailyInfo queryByMobile(String userMobile,String today )
    {
       
        HealthDailyInfo healthDailyInfo = healthDailyInfoService.queryByMobile(userMobile,today);
        return healthDailyInfo;
    }
    /**
     * 导出健康日报详情列表
     */
    @RequiresPermissions("healthinfo:healthdailyInfo:export")
    @Log(title = "健康日报详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(HealthDailyInfo healthDailyInfo)
    {
        List<HealthDailyInfo> list = healthDailyInfoService.selectHealthDailyInfoList(healthDailyInfo);
        ExcelUtil<HealthDailyInfo> util = new ExcelUtil<HealthDailyInfo>(HealthDailyInfo.class);
        return util.exportExcel(list, "healthdailyInfo");
    }

    /**
     * 新增健康日报详情
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存健康日报详情
     */
    @RequiresPermissions("healthinfo:healthdailyInfo:add")
    @Log(title = "健康日报详情", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(HealthDailyInfo healthDailyInfo)
    {
        return toAjax(healthDailyInfoService.insertHealthDailyInfo(healthDailyInfo));
    }

    /**
     * 修改健康日报详情
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        HealthDailyInfo healthDailyInfo = healthDailyInfoService.selectHealthDailyInfoById(id);
        mmap.put("healthDailyInfo", healthDailyInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存健康日报详情
     */
    @RequiresPermissions("healthinfo:healthdailyInfo:edit")
    @Log(title = "健康日报详情", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(HealthDailyInfo healthDailyInfo)
    {
        return toAjax(healthDailyInfoService.updateHealthDailyInfo(healthDailyInfo));
    }

    /**
     * 删除健康日报详情
     */
    @RequiresPermissions("healthinfo:healthdailyInfo:remove")
    @Log(title = "健康日报详情", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(healthDailyInfoService.deleteHealthDailyInfoByIds(ids));
    }
}
